package com.mango.algorithm.hash;

import cn.hutool.core.util.HashUtil;

/**
 * Hutool hash 算法
 * @Author: mango
 * @Date: 2022/5/19 11:30 下午
 */
public class HutoolHashTest {
    public static void main(String[] args) {

        String str = "中国";
        // additiveHash 加法hash
        int i1 = HashUtil.additiveHash(str, 2147483647);
        System.out.println("additiveHash:"+i1);

        // rotatingHash 旋转hash
        int i2 = HashUtil.rotatingHash(str, 2147483647);
        System.out.println("rotatingHash:"+i2);

        // oneByOneHash 一次一个hash
        int i3 = HashUtil.oneByOneHash(str);
        System.out.println("oneByOneHash:"+i3);

        // bernstein Bernstein's hash
        int i4 = HashUtil.bernstein(str);
        System.out.println("bernstein:"+i4);

        // fnvHash 改进的32位FNV算法1
        int i5 = HashUtil.fnvHash(str);
        System.out.println("fnvHash:"+i5);

        // intHash Thomas Wang的算法，整数hash
        int i6 = HashUtil.intHash(20000);
        System.out.println("intHash:"+i6);

        // rsHash RS算法hash
        int i7 = HashUtil.rsHash(str);
        System.out.println("rsHash:"+i7);

        // rsHash RS算法hash
        int i8 = HashUtil.jsHash(str);
        System.out.println("jsHash:"+i8);

        // pjwHash PJW算法
        int i9 = HashUtil.pjwHash(str);
        System.out.println("pjwHash:"+i9);

        // elfHash ELF算法
        int i10 = HashUtil.elfHash(str);
        System.out.println("elfHash:"+i10);

        // bkdrHash BKDR算法
        int i11 = HashUtil.bkdrHash(str);
        System.out.println("bkdrHash:"+i11);

        // sdbmHash SDBM算法
        int i12 = HashUtil.sdbmHash(str);
        System.out.println("sdbmHash:"+i12);

        // djbHash DJB算法
        int i13 = HashUtil.djbHash(str);
        System.out.println("djbHash:"+i13);

        // dekHash DEK算法
        int i14 = HashUtil.dekHash(str);
        System.out.println("dekHash:"+i14);

        // apHash AP算法
        int i15 = HashUtil.apHash(str);
        System.out.println("apHash:"+i15);

        // tianlHash TianL Hash算法
        long i16 = HashUtil.tianlHash(str);
        System.out.println("tianlHash:"+i16);

        // javaDefaultHash JAVA自己带的算法
        int i17 = HashUtil.javaDefaultHash(str);
        System.out.println("javaDefaultHash:"+i17);

        // mixHash 混合hash算法，输出64位的值
        long i18 = HashUtil.mixHash(str);
        System.out.println("mixHash:"+i18);

        /**
         * universal Universal Hashing
         * zobrist Zobrist Hashing
         */
    }
}
